// 公共方法调用区
//console.log("start")
function geetdata(url, opation, htmlurl, scripturl, cookies, isLog) {
	$.getJSON(url, opation, function(json) {
		// 日志打印模块
//		if (isLog) {
//			console.log("在geetdata函数中opation:");
//			console.info(opation);
//			console.log("在geetdata函数中接收的json.data");
//			console.info(json.data);
//			console.info("在geetdata函数中接收的json数据是");
//			console.log(json);
//		}

		view(json, htmlurl, scripturl); // 负责界面显示数据
	})
}
function view(json, htmlurl, scripturl) {
	var $varietyContent = $(htmlurl), varietyHtml = template(scripturl, json);
	$varietyContent.html(varietyHtml);

}

function pre(name, url, htmlurl, scripturl, cookies, isLog) {
	var value = $.cookie(name);
	var opation = JSON.parse(value);
	if (opation.pageNo > 1) {
		opation.pageNo = opation.pageNo - 1;
	}
	geetdata(url, opation, htmlurl, scripturl, name, isLog);
//	console.log("在pre函数中opation的内容是")
//	console.info(opation);
}
function next(name, url, htmlurl, scripturl, cookies, isLog) {
	var value = $.cookie(name);
	var opation = JSON.parse(value);
	if (opation.pageNo < opation.pageCount) {
		opation.pageNo = opation.pageNo + 1;
	}
	geetdata(url, opation, htmlurl, scripturl, name, isLog);
//	console.log("在next函数中opation的内容是")
//	console.info(opation);
}

function geetImg(imgUrl, n) {
	if (imgUrl == '') {
		return null;
	}
	if (n == '') {
		return imgUrl;
	}
	var imgurls = new Array();
	imgurls = imgUrl.split(',');
	if (n > imgurls.length + 1) {
		alert('传递的参数有误！');
	} else {
		return imgurls[n - 1];
	}
	return '';
}
template.helper("geetImgByIndex", geetImg);
//console.log("end");

/**
 * 调用示例： 1.改变图片选取位置
 * 
 * <img src="{{value.imgUrl | geetImgByIndex:'1'}}" alt="图片"/>
 */

